package cn.tedu.csms.job.controller;

import cn.tedu.csms.base.response.JsonResult;
import cn.tedu.csms.job.pojo.dto.EmpeLoginQuery;
import cn.tedu.csms.job.pojo.dto.JobSaveParam;
import cn.tedu.csms.job.pojo.vo.JobVO;
import cn.tedu.csms.job.service.JobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "员工工作板块")
@RestController
@Slf4j
@RequestMapping("/v1/job")
public class JobController {
    @Autowired
    JobService jobService;
    @PostMapping("login")
    @ApiOperation(value = "用户登录")
    public JsonResult login(EmpeLoginQuery empeLoginQuery) {
        log.debug("用户登录，参数={}", empeLoginQuery);
        jobService.login(empeLoginQuery);
        return JsonResult.ok();
    }
    @PostMapping("save")
    @ApiOperation(value = "保存员工工作信息")
    public JsonResult saveJob(JobSaveParam jobSaveParam) {
        log.debug("新增员工工作信息，参数={}", jobSaveParam);
        jobService.saveJob(jobSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("delete/{id}")
    @ApiOperation(value = "删除员工工作信息")
    public JsonResult deleteJob(@PathVariable Long id) {
        log.debug("删除员工工作信息，参数={}",id);
        jobService.deleteById(id);
        return JsonResult.ok();
    }
    @GetMapping("select")
    @ApiOperation(value = "加载工作信息")
    public JsonResult selectJob(EmpeLoginQuery empeLoginQuery) {
        log.debug("加载工作信息：{}",empeLoginQuery);
        List<JobVO> list = jobService.select(empeLoginQuery);
        return JsonResult.ok(list);
    }
    @PostMapping("update/status/{id}/{status}")
    @ApiOperation(value = "修改员工状态")
    public JsonResult updateJobStatus(@PathVariable Integer id, @PathVariable String status) {
        log.debug("修改员工状态：{}",id,status);
        jobService.updateStatus(id,status);
        return JsonResult.ok();
    }

    @GetMapping("select/empes/{shopId}")
    @ApiOperation(value = "获取店铺员工信息")
    public JsonResult selectEmpes(@PathVariable Long shopId) {
        log.debug("查询员工信息：{}",shopId);
        List<JobVO> list = jobService.selectEmpesByShopId(shopId);
        return JsonResult.ok(list);
    }


}
